from langgraph.prebuilt import create_react_agent
from langgraph.config import get_stream_writer
from langchain_ollama import ChatOllama

llm = ChatOllama(model="qwen3:8b", reasoning=False, temperature=0.2)

def get_weather(city: str) -> str:
    """Get weather for a given city."""
    writer = get_stream_writer()
    # stream any arbitrary data
    writer(f"Looking up data for city: {city}")
    return f"It's always sunny in {city}!"
agent = create_react_agent(
    model=llm,
    tools=[get_weather],
)

for chunk in agent.stream(
    {"messages": [{"role": "user", "content": "what is the weather in sf"}]},
    stream_mode="custom"
):
    print(chunk)
    print("\n")
